Repository navigation
Conversation
7aa4ef4 to
50703ec
Compare
| // Before date promotion, bounds were stored as days since the epoch. | ||
| const auto units_per_day = type_id == TypeId::kTimestamp ? internal::kMicrosPerDay | ||
| : internal::kNanosPerDay; | ||
| ICEBERG_ASSIGN_OR_RAISE(auto timestamp, MultiplyExact(value, units_per_day)); |
There was a problem hiding this comment.
A file containing only epoch day 0 can have a valid loose date upper bound of day 106752. After promotion to timestamp_ns, the row is still representable, but MultiplyExact rejects the upper bound and aborts planning. Could we treat this bound as unknown while retaining overflow errors for actual row values?
There was a problem hiding this comment.
Bounds are now decoded through an internal DeserializeBound() that returns
std::nullopt when a four-byte date bound does not fit the promoted type.
Callers treat it as a missing bound, so planning continues and the other bound
stays usable. Literal::Deserialize() still returns an error on overflow, and
malformed bounds are still propagated as errors.
3306bcc to
4bb3a9f
Compare
| return bound; | ||
| } | ||
| SingleValueStructLike data(std::move(*bound)); | ||
| return term.Evaluate(data); |
There was a problem hiding this comment.
The later of the two timestamp examples in Appendix B maps to bucket 0, while the earlier one maps to bucket 1. Taking the bucket of the upper bound returns the wrong MAX. Require an order-preserving transform before deriving an extremum from one endpoint.
There was a problem hiding this comment.
MIN/MAX now use file bounds only for column references and order-preserving transforms. I added a regression test using the two timestamps from Appendix B.
| ICEBERG_UNWRAP_OR_FAIL(auto upper, | ||
| Literal::Timestamp(2 * internal::kMicrosPerDay + 1).Serialize()); | ||
| DataFile file{.record_count = 1, .upper_bounds = {{1, upper}}}; | ||
| EXPECT_TRUE(max_day->HasValue(file)); |
There was a problem hiding this comment.
A file containing only day 1 may have an upper bound on day 2. What guarantees this bound is exact? Please cover that case and fall back when the metrics cannot establish the MAX.
There was a problem hiding this comment.
Nothing in DataFile says whether a bound is exact, so the aggregate cannot
detect this case. This is the same contract as Java's MaxAggregate, which
returns the bound as is and leaves it to the caller to decide whether bounds can
be trusted. This PR does not change that; the test only checks that the bound is
decoded with the source column type.
| // https://iceberg.apache.org/spec/#schema-evolution | ||
| auto timestamp = PromoteDate(value, type_id); | ||
| if (!timestamp) { | ||
| return InvalidArgument("Date {} is outside the range of {}", value, |
There was a problem hiding this comment.
ManifestEvaluator still reaches this error for partition summaries. An old identity-date manifest may contain day 1 with a loose upper bound of day 106752. After promotion to timestamp_ns, keep that manifest for ts > epoch and distinguish an unrepresentable bound from an all-null summary.
There was a problem hiding this comment.
I think promoting an identity-partitioned date to timestamp_ns is disallowed because it changes the partition value. The day, month, and year transforms keep the same partition values across the promotion.
Read four-byte bounds for timestamp and timestamp_ns as epoch days. Treat date bounds outside the target range as unknown when evaluating file and manifest statistics, while propagating malformed bounds as errors.
Require all four bounds for equality delete range checks. Keep partition summary evaluation on its existing path and cover timestamp source bounds in transformed aggregates and inclusive file pruning.
Bucket numbers can decrease as source values increase. Applying bucket to a file's upper bound can therefore produce the wrong maximum, even when the bound is the largest value in the file. Use source bounds only for references and order-preserving transforms. Counts can still establish a null result for an all-null column.
The void transform returns null for every input. Return a typed null before reading file metrics so both accumulators stay valid with or without source bounds.
8c86683 to
9b82e2d
Compare
After a
datecolumn is promoted totimestamportimestamp_ns, existing fileskeep four-byte bounds in days. Per the spec's schema evolution rules, decode them
as midnight in the target unit instead of reading the day count as micros/nanos.
Without this, inclusive pruning can drop files that contain matching rows, and
strict evaluation can report that all rows match when they do not.
Changes:
Conversions::FromBytesscales four-byte bounds fortimestampandtimestamp_ns, and returns an error on overflow.time,timestamptz, andtimestamptz_nsare nowrejected; the spec does not allow date promotion to those types.
internal
DeserializeBoundthat treats an out-of-range date bound as unknownrather than failing planning. Malformed bounds are still errors.
type-changing transforms such as
max(day(ts)).Related to #1156 and #1153.